package ${element.packagePath!}.${element.controllerPackageName!};

import org.springframework.web.bind.annotation.*;
<#if element.isSwagger == 1>
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
</#if>
import org.springframework.beans.factory.annotation.Autowired;
import ${element.packagePath!}.${element.servicePackageName!}.${element.beanName!}Service;
import ${element.packagePath!}.${element.beanPackageName!}.${element.beanName!}Entity;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
*<p>
*   ${element.notesTable!}前端控制器
*</p>
*
* @author ${element.author!}
* @since ${element.date!}
*/
@RestController
@RequestMapping("${element.beanCaseName!}")
<#if element.isSwagger == 1>
@Api(tags = "${element.notesTable!}")
</#if>
public class ${element.beanName!}Controller{

    @Autowired
    private  ${element.beanName!}Service ${element.beanCaseName!}Service;


    /**
    * 根据id查询${element.notesTable!}
    * @param  id
    * @return Page
    */
    @GetMapping("get${element.beanCaseName!}ById/{id}")
    <#if element.isSwagger == 1>
    @ApiOperation("根据id查询${element.notesTable!}")
    </#if>
    public R get${element.beanName!}ById(@PathVariable("id") String id){
        return R.ok().data("info",${element.beanCaseName!}Service.get${element.beanName!}ById(id));
    }

    /**
    * 保存${element.notesTable!}
    * @param ${element.beanCaseName!} 实体类
    * @return
    */
    @PostMapping("save${element.beanName!}")
    <#if element.isSwagger == 1>
    @ApiOperation("保存${element.notesTable!}")
    </#if>
    public R save${element.beanName!}(@RequestBody ${element.beanName!}Entity ${element.beanCaseName!}){

        ${element.beanCaseName!}Service.save${element.beanName!}(${element.beanCaseName!});
        return R.ok();
    }

    /**
    * 更新${element.notesTable!}
    * @param ${element.beanCaseName!} 实体类
    * @return
    */
    @PostMapping("update${element.beanName!}")
    <#if element.isSwagger == 1>
    @ApiOperation("更新${element.notesTable!}")
    </#if>
    public R upt${element.beanName!}(@RequestBody ${element.beanName!}Entity ${element.beanCaseName!}){
        ${element.beanCaseName!}Service.update${element.beanName!}(${element.beanCaseName!});
        return R.ok();
    }

    /**
    * 分页查询${element.notesTable!}
    * @param queryPageInfo 分页查询公共类
    * @return Page
    */
    @PostMapping("query${element.beanName!}Page")
    <#if element.isSwagger == 1>
    @ApiOperation("分页查询${element.notesTable!}")
    </#if>
    public R query${element.beanName!}Page(@RequestBody QueryPageInfo<${element.beanName!}Entity> queryPageInfo){
        Page<${element.beanName!}Entity> page = ${element.beanCaseName!}Service.query${element.beanName!}Page(queryPageInfo.getPage()
                                                                                ,queryPageInfo.getParameter());
        return R.ok().data("page",page);
    }

    /**
    * 删除${element.notesTable!}
    * @param id 主键
    * @return
    */
    @DeleteMapping("delete${element.beanName!}/{id}")
    <#if element.isSwagger == 1>
        @ApiOperation("删除${element.notesTable!}")
    </#if>
    public R delete${element.beanName!}(@PathVariable("id") String id){
        ${element.beanCaseName!}Service.delete${element.beanName!}(id);
        return R.ok();
    }

}
